package org.ushio.nchu_22201404.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.ushio.common_module.entity.ComplaintRecord;
import org.ushio.common_module.entity.RepairRecord;
import org.ushio.nchu_22201404.service.MaintainRecordService;

import java.util.List;

@CrossOrigin(origins = "http://localhost:8080")
@RestController
public class MaintainRecordController {
    @Autowired
    private MaintainRecordService maintainRecordService;

    @PostMapping("/maintainInsert")
    public String maintainInsert(@RequestBody RepairRecord repairRecord){
        maintainRecordService.maintainInsert(repairRecord);
        return "维修记录提交成功，请耐心等待客服回复";
    }

    @PostMapping("/maintainSetIssueResolved")
    public String maintainSetIssueResolved(@RequestBody RepairRecord repairRecord){
        maintainRecordService.maintainSetIssueResolved(repairRecord);
        return "Maintain Record Update success";
    }

    @RequestMapping("/maintainGetIssueResolved")
    public RepairRecord maintainGetIssueResolved(@RequestParam String phoneNumber){
        return maintainRecordService.maintainGetIssueResolved(phoneNumber);
    }

    @PostMapping("/maintainSetIsSigned")
    public void maintainSetIsSigned(@RequestBody RepairRecord repairRecord){
        maintainRecordService.maintainSetIsSigned(repairRecord);
    }

    @RequestMapping("/maintainGetIsSigned")
    public RepairRecord maintainGetIsSigned(@RequestParam String phoneNumber){
        return maintainRecordService.maintainGetIsSigned(phoneNumber);
    }

    @RequestMapping("/maintainSelectToCustomerService")
    public List<RepairRecord> maintainSelectToCustomerService(){
        return maintainRecordService.maintainSelectToCustomerService();
    }

    @RequestMapping("/maintainSelectToAdmin")
    public List<RepairRecord> maintainSelectToAdmin(){
        return maintainRecordService.maintainSelectToAdmin();
    }

    @RequestMapping("/maintainGetByPhoneNumber")
    public List<RepairRecord> maintainGetByPhoneNumber(@RequestParam String phoneNumber){
        return maintainRecordService.maintainSelectByPhoneNumber(phoneNumber);
    }
}
